package com.example.mall.service.impl;

import com.example.mall.mbg.mapper.ScreenMapper;
import com.example.mall.mbg.model.Screen;
import com.example.mall.mbg.model.ScreenExample;
import com.example.mall.service.ScreenService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ScreenServiceImpl
 * Created by on 2023/12/27.
 */
@Service
public class ScreenServiceImpl implements ScreenService {
    @Autowired
    private ScreenMapper screenMapper;

    @Override
    public List<Screen> listAll() {
        return screenMapper.selectByExample(new ScreenExample());
    }

    @Override
    public int create(Screen screen) {
        return screenMapper.insertSelective(screen);
    }

    @Override
    public int update(Integer screenid, Screen screen) {
        screen.setScreenid(screenid);
        return screenMapper.updateByPrimaryKeySelective(screen);
    }

    @Override
    public int delete(Integer screenid) {
        return screenMapper.deleteByPrimaryKey(screenid);
    }

    @Override
    public List<Screen> list(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return screenMapper.selectByExample(new ScreenExample());
    }

    @Override
    public Screen get(Integer screenid) {
        return screenMapper.selectByPrimaryKey(screenid);
    }
}
